#pragma once
#include"Hash.h"
#include<string>
namespace Zhj
{
	template <class K, class V,class Hash=HashFun<K>>
	class Unordered_Map
	{
	public:
		struct MapkeyofT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};


		bool insert(const pair<K,V>&kv)
		{
			return ht.Insert(kv);
		}

		Hashbuck::Hashtable<K, pair<K, V>, MapkeyofT> ht;
		typedef typename Hashbuck::Hashtable<K, pair<K,V>, MapkeyofT, Hash>::iterator iterator;

		iterator begin()
		{
			return ht.begin();
		}
		iterator end()
		{
			return ht.end();
		}

		
	};
	void test_map()
	{
		Unordered_Map<string, string> dict;
		dict.insert(make_pair("sort", "11"));
		dict.insert(make_pair("string", "22"));
		dict.insert(make_pair("insert", "33"));

		for (auto& kv:dict)
		{
			//kv.first += 'x';
			//kv.second += 'x';

			cout << kv.first << ":" << kv.second << endl;
		}
		cout << endl;
	}
}
